home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9387 < prev    next >
Encoding:
Text File  |  1996-08-05  |  699 b   |  37 lines

  1. Path: news.hklink.net!usenet
  2. From: alex@station.net (Alex Chu)
  3. Newsgroups: comp.lang.c
  4. Subject: malloc question
  5. Date: Sun, 10 Mar 1996 05:26:29 GMT
  6. Organization: HongKongLink (Tel: 23882399 Fax: 23882188 Net: info@hklink.net)
  7. Message-ID: <4htonk$350@news.hklink.net>
  8. NNTP-Posting-Host: ttyl3.station.net
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11.  
  12. Hi everybody,
  13.  
  14. I have a question for the following snip C program.
  15.  
  16. typedef struct item {
  17.   int val;
  18.   struct item *next;
  19. } ITEM, *PITEM;
  20.  
  21. main()
  22. {
  23.   PITEM head, current;
  24.   head=(PITEM) malloc(sizeof(ITEM));
  25.             ^^^^^^^
  26.   head->val=1;
  27. }
  28.  
  29. I want to know why need to use the type casting PITEM in front of the
  30. malloc ?  Please help!
  31.  
  32.  
  33. Alex Chu
  34.   
  35.  
  36.  
  37.